package com.neusoft.resturant.controller;

import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResReview;
import com.neusoft.resturant.service.IResReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 评论Controller
 * 
 * @author zhengzijia0934
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/api/review")
public class ResReviewController
{
    @Autowired
    private IResReviewService resReviewService;

    /**
     * 查询评论列表
     */
    @GetMapping("/list")
    public R list(ResReview resReview)
    {
        List<ResReview> list = resReviewService.selectResReviewList(resReview);
        return R.success(list);
    }

    /**
     * 导出评论列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResReview resReview)
    {
        List<ResReview> list = resReviewService.selectResReviewList(resReview);
    }

    /**
     * 获取评论详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {
        return R.success(resReviewService.selectResReviewById(id));
    }

    /**
     * 新增评论
     */
    @PostMapping
    public R add(@RequestBody ResReview resReview)
    {
        return R.toAjax(resReviewService.insertResReview(resReview));
    }

    /**
     * 修改评论
     */
    @PutMapping
    public R edit(@RequestBody ResReview resReview)
    {
        return R.toAjax(resReviewService.updateResReview(resReview));
    }

    /**
     * 删除评论
     */
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.toAjax(resReviewService.deleteResReviewByIds(ids));
    }
}
